package com.nervenets.web.controller.handler.user.user;

import com.nervenets.web.controller.handler.Handler;
import com.nervenets.web.controller.handler.common.IdTokenParams;

import javax.servlet.http.HttpServletRequest;

public class UserAddressDefHandler extends Handler<IdTokenParams> {
    @Override
    public String handle(IdTokenParams params, HttpServletRequest request) throws Exception {
        userDao.getJdbcTemplate().execute("update addresses set def = false where userId = " + params.getUserId());
        userDao.getJdbcTemplate().execute("update addresses set def = true where id = " + params.getTargetId());
        return successMessage();
    }

    @Override
    public String result() throws Exception {
        return successMessage();
    }
}
